package edu.jhu.cs.oose.scheduleit.services;

import java.util.List;

import edu.jhu.cs.oose.scheduleit.services.impl.DataBaseException;
import edu.jhu.cs.oose.scheduleit.util.Attribute;
import edu.jhu.cs.oose.scheduleit.util.Filter;
import edu.jhu.cs.oose.scheduleit.util.ScheduleType;
import edu.jhu.cs.oose.scheduleit.vo.Schedule;
import edu.jhu.cs.oose.scheduleit.vo.User;

/**
 * An interface for service related to schedule
 * @author oose_group2
 *
 */
public interface ScheduleService {
	
	/**
	 * Create a new schedule
	 * @param user	The user who creates the new schedule
	 * @param attribute	The attribute of the new schedule
	 * @return	The new schedule created
	 * @throws DataBaseException	If a DataBaseException occurred
	 */
	public Schedule createSchedule(User user, Attribute attribute) throws DataBaseException;
	/**
	 * Create a merged schedule
	 * @param user The user who creates the merged schedule
	 * @param mergedSchedules the schedules which are used to merge.
	 * @return The merged schedule created
	 * @throws DataBaseException  If a DataBaseException occurred
	 */
	public Schedule createSchedule(User user, List<Schedule> mergedSchedules) throws DataBaseException;
	
	/**
	 * Subscribe to a certain schedule
	 * @param user	The user who wants to subscribe a certain schedule
	 * @param subscribedSchedule	The schedule subscribed by a user
	 * @throws DataBaseException	If a DataBaseException occurred
	 */
	public void addSubscribedSchedule(User user, Schedule subscribedSchedule) throws DataBaseException;
	
	/**
	 * Remove a schedule
	 * @param schedule	The schedule going to be removed
	 * @throws DataBaseException	If a DataBaseException occurred
	 */
	public void removeSchedule(Schedule schedule)throws DataBaseException;
	
	/**
	 * Update the information of a certain schedule
	 * @param schedule	The schedule going to be updated
	 * @throws DataBaseException	If a DataBaseException occurred
	 */
	public void updateSchedule(Schedule schedule) throws DataBaseException;

	/**
	 * Retrieve the schedules satisfying given conditions
	 * By assigning offset and limit, the method would return a part of of the fulfilled result
	 * @param user	The user who owns the objective schedules
	 * @param type	The type of objective schedules
	 * @param offset	The offset of the first schedule in the list
	 * @param limit		The limit number of the objective schedules
	 * @return	The schedules satisfying given conditions
	 * @throws DataBaseException
	 */
	public List<Schedule> getSchedule(User user, ScheduleType type, int offset, int limit) throws DataBaseException;
	
	/**
	 * Get the schedules which are fulfill with the given condition from whole database.
	 * By assigning offset and limit, the method would return a part of of the fulfilled result
	 * @param filters the search condition
	 * @param offset it's the number to skip. If offset = 0, the return event is start from the first event. 
	 *             <br> If offset =1, the return event is start from the second event.
	 * @param limit it's the maximum return size. If limit <0 , means no limitation.
	 * @return a list of schedule
	 * @throws DataBaseException If there is any data base exception, an exception will be throw out
	 */
	public List<Schedule> getSchedule(List<Filter> filters, int offest, int limit) throws DataBaseException;

	/**
	 * Calculate how many schedules satisfying the given condition
	 * @param filters the search condition
	 * @return	The number of how many schedules satisfying the given conditions
	 * @throws DataBaseException	If a DataBaseException occurred
	 */
	public int getScheduleCount(List<Filter> filters) throws DataBaseException;
	
	/**
	 * Retrieve the schedule with certain id and hosted by certain user
	 * @param user	The user hosting the objective schedule
	 * @param scheduleID	The id of the objective schedule
	 * @return	The schedule with certain id and hosted by certain user
	 * @throws DataBaseException	If a DataBaseException occurred
	 */
	public Schedule getSchedule(User user,int scheduleID) throws DataBaseException;
	
	/**
	 * Calculate how many schedules of certain type, owned by a given user
	 * @param user	The user who owns the objective schedule
	 * @param type	The type of the objective schedule
	 * @return	The number of how many schedules satisfying the given conditions
	 * @throws DataBaseException	If a DataBaseException occurred
	 */
	public int getScheduleCount(User user, ScheduleType type) throws DataBaseException;
	
}
